<!DOCTYPE html>
<html lang="en">
<head>
    <title>three.js webgl - materials</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <link type="text/css" rel="stylesheet" href="css/main.css">
</head>
<body>

<div id="container"></div>
<div id="info"><a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> - Lambert Material Variantions by <a href="http://clara.io/" target="_blank" rel="noopener">Ben Houston</a>.</div>

<script type="module">

    import * as THREE from './build/three.module.js';

    import Stats from './threejs/jsm/libs/stats.module.js';

    import { OrbitControls } from './threejs/jsm/controls/OrbitControls.js';

    import { TTFLoader } from './threejs/jsm/loaders/TTFLoader.js';
    let container, stats;

    let camera, scene, renderer;
    let particleLight;
    import { TWEEN } from './threejs/jsm/libs/tween.module.min.js';
    const loader = new THREE.FontLoader();
    loader.load( 'threejs/fonts/gentilis_regular.typeface.json', function ( font ) {


    // const loader = new TTFLoader();
    //
    // loader.load( 'threejs/fonts/ttf/SourceHanSerifCN-SemiBold.otf', function ( font ) {


        init( font );
        animate();

    } );

    //
    // loader.load( 'threejs/fonts/33.json', function ( font ) {
    //
    //     init( font );
    //     animate();
    //
    // } );

    function init( font ) {

        container = document.createElement( 'div' );
        document.body.appendChild( container );

        camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 2500 );
        camera.position.set( 0.0, 400, 400 * 3.5 );

        //

        const reflectionCube = new THREE.CubeTextureLoader()
            .setPath( './threejs/textures/cube/SwedishRoyalCastle/' )
            .load( [ 'px.jpg', 'nx.jpg', 'py.jpg', 'ny.jpg', 'pz.jpg', 'nz.jpg' ] );
        reflectionCube.encoding = THREE.sRGBEncoding;

        scene = new THREE.Scene();
        scene.background = reflectionCube;


        // camera.rotation.x+=0.001



        // var p1 = {x:0,y:10,z:20};
        // var tweena = cameraCon({x:20,y:2,z:0},9000);
        // var tweenb = cameraCon({x:0,y:10,z:-20},9000);
        // var tweenc = cameraCon({x:-20,y:2,z:0},4000);
        // var tweend = cameraCon({x:0,y:10,z:20},4000);
        // tweena.chain(tweenb);
        // tweenb.chain(tweenc);
        // tweenc.chain(tweend);
        // tweend.chain(tweena);
        // tweena.start();
        //
        // function cameraCon(p2={x:10,y:30,z:10},time=6000) {
        //     var tween1 = new TWEEN.Tween(p1).to(p2,time).easing(TWEEN.Easing.Quadratic.InOut);
        //     console.log("sdfsdf12312313")
        //     var update = function () {
        //         console.log("sdfsdf12312313")
        //         camera.position.set(p1.x,p1.y,p1.z);
        //     };
        //     tween1.onUpdate(update);
        //     console.log("sdfsdf12312313")
        //     return tween1;
        // }


        renderer = new THREE.WebGLRenderer( { antialias: true } );
        renderer.setPixelRatio( window.devicePixelRatio );
        renderer.setSize( window.innerWidth, window.innerHeight );
        container.appendChild( renderer.domElement );
        renderer.outputEncoding = THREE.sRGBEncoding;

        //

        stats = new Stats();
        container.appendChild( stats.dom );

        const controls = new OrbitControls( camera, renderer.domElement );
        controls.minDistance = 200;
        controls.maxDistance = 2000;

        window.addEventListener( 'resize', onWindowResize, false );


        let texture=new THREE.TextureLoader();
        let cubeTexture=texture.load("./textures/camera/camera.png");

        let dosize = 1000/10
        // 添加平面几何体
        // let  geometryss = new THREE.BoxBufferGeometry(dosize, dosize,dosize);
        let  geometryss = new THREE.PlaneBufferGeometry(dosize, dosize,dosize);
        let materialss = new THREE.MeshBasicMaterial({map:cubeTexture});
        let materialss2 =[materialss,materialss,materialss,materialss,materialss,materialss]
        let Mesh = new THREE.Mesh(geometryss,materialss)

        scene.add(Mesh)

    }

    function onWindowResize() {

        camera.aspect = window.innerWidth / window.innerHeight;
        camera.updateProjectionMatrix();

        renderer.setSize( window.innerWidth, window.innerHeight );

    }

    //

    function animate() {

        requestAnimationFrame( animate );

        render();
        stats.update();

    }

    function render() {

        const timer = Date.now() * 0.00025;

        //camera.position.x = Math.cos( timer ) * 800;
        //camera.position.z = Math.sin( timer ) * 800;

        // camera.lookAt( scene.position );

        renderer.render( scene, camera );

    }

</script>

</body>
</html>
